package com.glodon.paas.account.web.resource;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;

import com.glodon.paas.account.api.bean.User;
import com.glodon.paas.account.service.UserService;
import com.glodon.paas.account.web.util.UserInfoMappingUtil;
import com.glodon.paas.web.resource.BaseResource;

public abstract class UserResource implements BaseResource{
	@Autowired
	private UserService userService;
	
	@GET
	@Path("/")
	@Produces(MediaType.APPLICATION_JSON)
	@Consumes(MediaType.APPLICATION_JSON)
	public User getUser(@Context HttpServletRequest request) {
		User user = UserInfoMappingUtil.fillUserPropertyText(userService.getUserInfoById(getUserId(request)));
		getLoger().debug("Get User ["+user.getEmail()+" success.");
		return user;
	}
}
